# # 固定角度转转图片
# import cv2
# import numpy as np
#
# # 读取图像
# image = cv2.imread('C:\\Users\\kaifacs\\Desktop\\2222.jpg')
#
# # 图像中心点
# (h, w) = image.shape[:2]
# center = (w // 2, h // 2)
#
# # 假设 YOLO 模型输出的角度是 45 度（逆时针）
# angle = 88
#
# # 获取旋转矩阵
# M = cv2.getRotationMatrix2D(center, angle, 1.0)
#
# # 计算旋转后的边界框大小
# cos = np.abs(M[0, 0])
# sin = np.abs(M[0, 1])
#
# new_width = int((h * sin) + (w * cos))
# new_height = int((h * cos) + (w * sin))
#
#
# # 应用旋转
# rotated_image = cv2.warpAffine(image, M,(new_width, new_height))
#
# # 调整旋转矩阵以考虑新的图像中心
# M[0, 2] += (new_width / 2) - center[0]
# M[1, 2] += (new_height / 2) - center[1]
#
#
# # 显示原图和旋转后的图像
# cv2.imshow('Original Image', image)
# cv2.imshow('Rotated Image', rotated_image)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
